package mysql.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "USERS")
public class User extends BaseEntity {
    @Column(nullable = false, unique = true)
    private String username;

    @Column(nullable = false, columnDefinition = "char(6) default 123456")
    private String password;

    @OneToMany(mappedBy = "user", cascade = {CascadeType.PERSIST})
    private Set<Order> orders = new HashSet<>();

//    @OneToOne(cascade = {CascadeType.ALL})
//    @JoinColumn(name = "ORDER_ID", referencedColumnName = "ID")
//    private Order order;
}
